#coding:utf-8
'''
create on 2017-07-22
@author:sandy
'''
import logging
import mjConst
import UserManager
import HallManager
from pycommon import Pack as packet

def cmdPlayCard(client,pkt):
    card = packet.unpack("H",pkt)
    uid = client.getUid()
    user = UserManager.instance.getUser(uid)
    hallId = user.getHallId()
    tableId = user.getTableId()
    logging.debug("hallId=%d tableId=%d uid=%d playcard card=%d",hallId,tableId,uid,card)
    hall = HallManager.instance.getHall(hallId)
    table = hall.getTable(tableId)
    table.playCard(uid,card)
    pass

def cmdChiPGH(client,pkt):
    chose = packet.unpack("B",pkt)
    

#==============================================================================

__cmdTable = {
                mjConst.CMD_C2G_PLAY_CAR : cmdPlayCard,
                mjConst.CMD_C2G_HPGC     : cmdChiPGH
             } 

def parse(client, cmd, pkt):
    func = __cmdTable.get(cmd)
    if func :
        func(client, pkt)
    else:
        logging.error("cmd = %d not found",cmd);

if __name__ == '__main__':
    pass